package com.csii.poi.test.dao;

import com.csii.poi.test.Entity.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.test.context.junit4.SpringRunner;

import java.sql.SQLException;
import java.util.List;

/**
 * ClassName:
 * Description:
 *
 * @author: allen_zyg
 * @date: 2020/7/4 0027 15:27
 */

public class UserMapper {
	//注入dao
	@Autowired
	private static JdbcTemplate template;

	/**
	 * 测试使用jdbcTemlter连接数据库
	 *
	 * @throws SQLException
	 */
	public static void main(String[] args) {


		//List<Map<String, Object>> list  = template.queryForList("select  * from user ",);
		RowMapper<User> rowMapper = new BeanPropertyRowMapper<User>(User.class);
		List<User> query = template.query("select  * from user ", rowMapper);
		for (User user : query) {
			System.out.println("user:" + user.toString());


		}
	}

}
